#include<cstdio>
using namespace std;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	int n,L,R;
	scanf("%d %d %d",&n,&L,&R);
	if(L-R+1>=n)
		printf("%d",n-1);
	else
	{
		if(R-L+L%n>=n-1)
			printf("%d",n-1);
		else
			printf("%d",R-L+L%n);
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
